import com.android.build.api.instrumentation.FramesComputationMode
import com.android.build.api.instrumentation.InstrumentationScope
import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.gradle.AppExtension
import org.gradle.api.Plugin
import org.gradle.api.Project

/**
 * author： suliang
 * 2022/10/20 18:04
 * describe :
 */
class NewPlugin : Plugin<Project>{
    override fun apply(target: Project) {
        log("======== start apply ========")
        log("apply target: ${target.displayName}")

        val androidComponents = target.extensions.getByType(AppExtension::class.java)
        androidComponents.registerTransform(NewTransform())

//        androidComponents.onVariants {
//            variant ->
//            variant.transformClassesWith(NewTransform::class.java,InstrumentationScope.ALL){
//                variant.setAsmFramesComputationMode(FramesComputationMode.COPY_FRAMES)
//            }
//        }
        log("========  end apply  ========")
    }
    private fun log(msg: String) {
        println("NewPlugin: $msg")
    }
}